import java.util.*;

public class Solution {

    //
    public static void main1(String[] args) {
        Scanner in = new Scanner(System.in);

        char[] s = in.next().toCharArray();
        int[] hash = new int[26];

        for(int i = 0; i < s.length; i++){
            hash[s[i] -'a']++;
        }

        int max = 0, min = 1000;
        for(int i = 0; i < 26; i++){
            if(hash[i] != 0){
                max = Math.max(max, hash[i]);
                min = Math.min(min, hash[i]);
            }
        }
        if(isPrim(max - min)){
            System.out.println("Lucky Word");
            System.out.println(max -min);
        }else{
            System.out.println("No Answer");
            System.out.println(0);
        }
    }

    public static boolean isPrim(int n){
        if(n < 2) { return false;}
        for(int i = 2; i <= Math.sqrt(n); i++){
            if(n % i == 0){
                return false;
            }
        }
        return true;
    }

    //
    public boolean hostschedule (ArrayList<ArrayList<Integer>> schedule) {

        int m = schedule.size(), n = schedule.get(0).size();
        int[][] t = new int[m][n];
        for(int i = 0; i < m; i++){
            for(int j = 0; j < n; j++){
                t[i][j] = schedule.get(i).get(j);
            }
        }

        Arrays.sort(t, (v1, v2) -> {
            return v1[0] - v2[0];
        });

        for(int i = 1; i < schedule.size(); i++){
            if(t[i][0] < t[i - 1][1]){
                return false;
            }
        }
        return true;
    }

    //
    public static int N = 510, M = 510 * 110 / 2;

    public static int n;
    public static int[] arr = new int[N];
    public static boolean[][] dp = new boolean[N][M];

    public static void main2(String[] args) {
        Scanner in = new Scanner(System.in);

        n = in.nextInt();
        int sum = 0;
        for(int i = 0; i < n; i++){
            arr[i] = in.nextInt();
            sum += arr[i];
        }

        if(sum % 2 == 1){
            System.out.println("false");
        }else{
            sum /= 2;
            dp[0][0] = true;
            for(int i = 1; i <= n; i++){
                for(int j = 0; j <= sum; j++){
                    dp[i][j] = dp[i - 1][j];
                    if(j >= arr[i]){
                        dp[i][j] = dp[i][j] || dp[i - 1][j - arr[i]];
                    }
                }
            }
            if(dp[n][sum]){
                System.out.println("true");
            }else{
                System.out.println("false");
            }
        }
    }

    //
    public static void main3(String[] args) {
        Scanner in = new Scanner(System.in);
        int l = in.nextInt(), r = in.nextInt();

        int t = 0;
        for(int i = l; i <= r; i++){
            t += check(i);
        }
        System.out.println(t);
    }

    public static int check(int n){
        int t = 0;
        while(n != 0){
            if(n % 10 == 2) {t++;}
            n /= 10;
        }
        return t;
    }

    //
    public ArrayList<Integer> intersection (ArrayList<Integer> nums1, ArrayList<Integer> nums2) {
        ArrayList<Integer> ans = new ArrayList<>();
        int[] hash = new int[1010];

        for(int i = 0; i < nums1.size(); i++){
            hash[nums1.get(i)]++;
        }

        for(int i = 0; i < nums2.size(); i++){
            if(hash[nums2.get(i)] != 0 && !ans.contains(nums2.get(i))){
                ans.add(nums2.get(i));
            }
        }
        return ans;
    }

    //
    public static void main4(String[] args) {
        Scanner in = new Scanner(System.in);
        char[] s = in.next().toCharArray();

        Stack<Character> stack = new Stack<>();
        for(char x : s){
            if(stack.isEmpty() || stack.peek() != x){
                stack.add(x);
            }else{
                stack.pop();
            }
        }
        StringBuffer buf = new StringBuffer();
        while(!stack.isEmpty()){
            buf.append(stack.pop());
        }

        if(buf.length() == 0){
            System.out.println("0");
        }else{
            System.out.println(buf.reverse().toString());
        }
    }

    //
    public static void main5(String[] args) {
        Scanner in = new Scanner(System.in);
        double a = in.nextDouble();
        char b = in.next().charAt(0);

        int price = 20;
        if(a > 1){
            price += (int)(a - 0.1);
        }

        if(b == 'y'){
            System.out.println(price + 5);
        }else{
            System.out.println(price);
        }
    }

    //
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] costs = new int[n];
        for(int i = 0; i < n; i++){
            costs[i] = in.nextInt();
        }

        int[] dp = new int[n + 1];
        for(int i = 2; i <= n; i++){
            dp[i] = Math.min(dp[i- 1] + costs[i - 1], dp[i - 2] + costs[i -2]);
        }
        System.out.println(dp[n]);
    }
}
